<template>
    <div class="photolist">
        <div class="lef">
            <el-aside width="auto" class="left">
                <el-form>
                    <el-tree :data="data" icon="Plus" />
                </el-form>

            </el-aside>
        </div>
        <div class="rig">
            <div class="top">
                <p>待审核列表</p>
            </div>
            <div class="box">
                <div class="content" v-for="item, index in list" :key="index">
                    <div class="text">
                        <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
                        <div class="wenzi">
                            <div>
                                <p>{{ item.name }}</p>
                                <p>{{ item.initTime }}</p>
                            </div>
                            <div>
                                <el-button type="success" @click="ty(item.id)">同意</el-button>
                                <el-button type="danger" @click="bh(item.id)">驳回</el-button>
                            </div>

                        </div>
                    </div>
                    <div class="miaoshu">
                        <p>{{ item.detail }}</p>
                    </div>
                    <div class="img">
                        <div class="one" v-for="items, indexs in list[index].photoList">
                            <img :src="items.img" alt="">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router';
import server from '@/api/index'
import { ref, onMounted } from 'vue'
import { ElNotification } from 'element-plus';
var router = useRouter()
var list = ref()

onMounted(async () => {
    var res = await server.home.photos_getPhotosByPage()
    // console.log(res.data.data.date);
    list.value = res.data.data.date

    list.value.forEach((item: any, index: any) => {
        // console.log(item.photoList);
        for (var key in item.photoList) {
            item.photoList[key].img = "http://43.143.177.23:8080" + item.photoList[key].img
            // console.log(item.photoList[key].img);
        }
    })
})
var gophoto = () => {
    router.push('/myphoto')
}
const data = [
    {
        label: '全部',
        children: [
            {
                label: '小学',
                children: [
                    {
                        label: '实验小学',
                        children: [
                            {
                                label: '一年级',
                                children: [
                                    {
                                        label: '一年级一班'
                                    },
                                    {
                                        label: '一年级二班'
                                    },
                                    {
                                        label: '一年级三班'
                                    },
                                ]
                            },
                            {
                                label: '二年级',
                                children: [
                                    {
                                        label: '二年级一班'
                                    },
                                    {
                                        label: '二年级二班'
                                    },
                                    {
                                        label: '二年级三班'
                                    },
                                ]
                            },
                            {
                                label: '三年级',
                                children: [
                                    {
                                        label: '三年级一班'
                                    },
                                    {
                                        label: '三年级二班'
                                    },
                                    {
                                        label: '三年级三班'
                                    },
                                ]
                            },
                        ]
                    }
                ]
            },
        ],
    },
]
var bh = async (id: any) => {
    var res = await server.home.deletePhotos(id)
    // console.log(res.data);
    if (res.data.code == 200) {
        ElNotification.success({ message: '删除成功' });
    } else {
        ElNotification.error({ message: '删除失败' });
    }
}
var ty = async (id: any) => {
    var res = await server.home.agree(id)
    // console.log(res.data);
    if (res.data.code == 200) {
        ElNotification.success({ message: '审核成功' });
    } else {
        ElNotification.error({ message: '审核失败' });
    }
}
</script>

<style scoped>
.photolist {
    height: 100%;
    width: 100%;
    /* padding: 20px 10px; */
    background: #f7f7f7;
    display: flex;
}

.lef {
    background: #fff;
    width: 20%;
    height: 750px;
    padding: 10px;
}

.rig {
    width: 80%;
    margin-left: 10px;
    background: #fff;
}

.el-menu {
    border-right: none;
}

.top {
    width: 95%;
    height: 50px;
    /* background: #aaa; */
    margin: 20px auto;
    /* line-height: 50px; */
    display: flex;
    font-size: 14px;
}


.el-tree {
    --el-tree-node-hover-bg-color: none
}

.box {
    width: 100%;
    height: 650px;
    overflow-y: auto;
}

.content {
    width: 100%;
    /* background: #aaa; */
    /* height: 1000px; */
    margin: 30px auto 0 auto;
}

.text {
    width: 100%;
    /* background: #ccc; */
    display: flex;
}

.wenzi {
    margin-left: 30px;
    font-size: 14px;
    color: #ccc;
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
}

.wenzi p:nth-child(2) {
    line-height: 28px;
}

.miaoshu {
    width: 400px;
    margin-left: 70px;
    line-height: 60px;
}

.img {
    width: 800px;
    margin-left: 70px;
    /* background: #ccc; */
    height: 500px;
    border-bottom: 1px solid #ccc;
    padding-bottom: 50px;
    display: flex;
    flex-wrap: wrap;
    justify-content: start;
}

.one {
    width: 30%;
    height: 210px;
    /* background: red; */
    border-radius: 5px;
    margin: 0 20px 0 0;
}

.one img {
    width: 100%;
    height: 100%;
}
</style>
